<template>
  <el-card>
    <el-form label-width="80px">
      <el-form-item label="广告名称">
        <el-input v-model="course.courseName"></el-input>
      </el-form-item>
      <el-form-item label="广告位置">
        <el-input v-model="course.brief"></el-input>
      </el-form-item>
      <el-form-item label="开始时间">
        <el-date-picker
          v-model="course.activityCourseDTO.beginTime"
          type="date"
          placeholder="选择日期时间"
          value-format="yyyy-MM-dd"
        />
      </el-form-item>
      <el-form-item label="到期时间">
        <el-date-picker
          v-model="course.activityCourseDTO.endTime"
          type="date"
          placeholder="选择日期时间"
          value-format="yyyy-MM-dd"
        />
      </el-form-item>
      <el-form-item label="上线">
        <el-switch
          v-model="course.activityCourse"
          active-color="#13ce66"
          inactive-color="#ff4949"
        >
        </el-switch>
      </el-form-item>
      <el-form-item label="广告链接">
        <el-input v-model="course.courseName"></el-input>
      </el-form-item>
      <el-form-item label="广告备注">
        <el-input v-model="course.courseName"></el-input>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script lang="ts">
import Vue from 'vue'
// import {
//   saveOrUpdateCourse,
//   getCourseById
// } from '@/services/course'
// import CourseImage from './CourseImage.vue'
// import TextEditor from '@/components/TextEditor/index.vue'
// import moment from 'moment'

export default Vue.extend({
  name: 'CreateOrUpdateCourse',
  props: {
    isEdit: {
      type: Boolean,
      default: false
    },
    courseId: {
      type: [String, Number]
    }
  },
  components: {
    // CourseImage,
    // TextEditor
  },
  data () {
    return {
      course: {
        // id: 0,
        courseName: '',
        brief: '',
        teacherDTO: {
          // id: 0,
          // courseId: 0,
          teacherName: '',
          teacherHeadPicUrl: '',
          position: '',
          description: ''
        },
        courseDescriptionMarkDown: '',
        price: 0,
        discounts: 0,
        priceTag: '',
        discountsTag: '',
        isNew: true,
        isNewDes: '',
        courseListImg: '',
        courseImgUrl: '',
        sortNum: 0,
        previewFirstField: '',
        previewSecondField: '',
        status: 0, // 0：未发布，1：已发布
        sales: 0,
        activityCourse: false, // 是否开启活动秒杀
        activityCourseDTO: {
          // id: 0,
          // courseId: 0,
          beginTime: '',
          endTime: '',
          amount: 0,
          stock: 0
        },
        autoOnlineTime: ''
      }
    }
  },
  created () {
    if (this.isEdit) {
      this.loadAdvert()
    }
  },
  methods: {
    async loadAdvert () {
      //   const {data} = await getCourseById(this.courseId)
      //   const {activityCourseDTO} = data.data
      //   if (activityCourseDTO) {
      //     activityCourseDTO.beginTime = moment(activityCourseDTO.beginTime).format('YYYY-MM-DD')
      //     activityCourseDTO.endTime = moment(activityCourseDTO.endTime).format('YYYY-MM-DD')
      //   }
      //   this.course = data.data
      // },
      //
      // async handleSave() {
      //   const {data} = await saveOrUpdateCourse(this.course)
      //   if (data.code === '000000') {
      //     this.$message.success('保存成功')
      //     this.$router.push('/course')
      //   } else {
      //     this.$message.error('保存失败')
      //   }
    }
  }
})
</script>

<style lang="scss" scoped>
  .el-step {
    cursor: pointer;
  }
</style>
